import 'dart:convert' show json;

import 'package:flutter_data_json_app/base/base_bean.dart';

class DeliverList extends BaseBean{

  int totalCount;
  List<DeliverSimple> list;

  DeliverList.fromParams({this.totalCount, this.list});

  factory DeliverList(jsonStr) => jsonStr == null ? DeliverList.fromParams() : jsonStr is String ? new DeliverList.fromJson(json.decode(jsonStr)) : new DeliverList.fromJson(jsonStr);

  DeliverList.fromJson(jsonRes) {
    totalCount = jsonRes['totalCount'];
    list = jsonRes['list'] == null ? null : [];

    for (var listItem in list == null ? [] : jsonRes['list']){
      list.add(listItem == null ? null : new DeliverSimple.fromJson(listItem));
    }
  }

  @override
  String toString() {
    return '{"totalCount": $totalCount,"list": $list}';
  }

  @override
  fromJson(jsonRes) {
    return DeliverList.fromJson(jsonRes);
  }

  @override
  bool dataIsEmpty() {
    // TODO: implement dataIsEmpty
    return list.isEmpty;
  }
}

class DeliverSimple {

  int deliverId;
  int loadTime;
  int ownerId;
  int srcCityId;
  int srcDistrictId;
  int status;
  int targetCityId;
  int targetDistrictId;
  int weight;
  double srcLatitude;
  double srcLongitude;
  double transAmount;
  String deliverNo;
  String goodsName;
  String goodsType;
  String goodsTypeName;
  String remark;
  String srcAddr;
  String srcCityName;
  String srcDistrictName;
  String targetAddr;
  String targetCityName;
  String targetDistrictName;

  DeliverSimple.fromParams({this.deliverId, this.loadTime, this.ownerId, this.srcCityId, this.srcDistrictId, this.status, this.targetCityId, this.targetDistrictId, this.weight, this.srcLatitude, this.srcLongitude, this.transAmount, this.deliverNo, this.goodsName, this.goodsType, this.goodsTypeName, this.remark, this.srcAddr, this.srcCityName, this.srcDistrictName, this.targetAddr, this.targetCityName, this.targetDistrictName});

  DeliverSimple.fromJson(jsonRes) {
    deliverId = jsonRes['deliverId'];
    loadTime = jsonRes['loadTime'];
    ownerId = jsonRes['ownerId'];
    srcCityId = jsonRes['srcCityId'];
    srcDistrictId = jsonRes['srcDistrictId'];
    status = jsonRes['status'];
    targetCityId = jsonRes['targetCityId'];
    targetDistrictId = jsonRes['targetDistrictId'];
    weight = jsonRes['weight'];
    srcLatitude = jsonRes['srcLatitude'];
    srcLongitude = jsonRes['srcLongitude'];
    transAmount = jsonRes['transAmount'];
    deliverNo = jsonRes['deliverNo'];
    goodsName = jsonRes['goodsName'];
    goodsType = jsonRes['goodsType'];
    goodsTypeName = jsonRes['goodsTypeName'];
    remark = jsonRes['remark'];
    srcAddr = jsonRes['srcAddr'];
    srcCityName = jsonRes['srcCityName'];
    srcDistrictName = jsonRes['srcDistrictName'];
    targetAddr = jsonRes['targetAddr'];
    targetCityName = jsonRes['targetCityName'];
    targetDistrictName = jsonRes['targetDistrictName'];
  }

  @override
  String toString() {
    return '{"deliverId": $deliverId,"loadTime": $loadTime,"ownerId": $ownerId,"srcCityId": $srcCityId,"srcDistrictId": $srcDistrictId,"status": $status,"targetCityId": $targetCityId,"targetDistrictId": $targetDistrictId,"weight": $weight,"srcLatitude": $srcLatitude,"srcLongitude": $srcLongitude,"transAmount": $transAmount,"deliverNo": ${deliverNo != null?'${json.encode(deliverNo)}':'null'},"goodsName": ${goodsName != null?'${json.encode(goodsName)}':'null'},"goodsType": ${goodsType != null?'${json.encode(goodsType)}':'null'},"goodsTypeName": ${goodsTypeName != null?'${json.encode(goodsTypeName)}':'null'},"remark": ${remark != null?'${json.encode(remark)}':'null'},"srcAddr": ${srcAddr != null?'${json.encode(srcAddr)}':'null'},"srcCityName": ${srcCityName != null?'${json.encode(srcCityName)}':'null'},"srcDistrictName": ${srcDistrictName != null?'${json.encode(srcDistrictName)}':'null'},"targetAddr": ${targetAddr != null?'${json.encode(targetAddr)}':'null'},"targetCityName": ${targetCityName != null?'${json.encode(targetCityName)}':'null'},"targetDistrictName": ${targetDistrictName != null?'${json.encode(targetDistrictName)}':'null'}}';
  }
}

